//
//  STBViewController.m
//  NuwaRobot
//
//  Created by Kendama on 2017/12/5.
//  Copyright © 2017年 Kendama. All rights reserved.
//

#import "STBViewController.h"
#import "EditHomeControlViewController.h"
#import "STBView.h"
#import "InfraredModel.h"

@interface STBViewController ()<STBViewDelegate>

@property(nonatomic,strong) STBView *containerView;

@end

@implementation STBViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [[DataManager sharedInstance] sendCode:@"1021" data:@{@"control_id":self.infraredModel.rid,@"control_code":@"0",@"type":_infraredModel.type}];
}

#pragma mark --- 点击事件
- (void)onRightButtonClick:(id)sender
{
    EditHomeControlViewController *vc = [EditHomeControlViewController new];
    vc.infraredModel = self.infraredModel;
    [self.navigationController pushViewController:vc animated:YES];
    
}

#pragma mark --- 代理
- (void)stbViewSelectedIndex:(NSInteger)index
{
    NSString *string = [NSString stringWithFormat:@"%li",(long)index];
    [[DataManager sharedInstance] sendCode:@"1021" data:@{@"control_id":self.infraredModel.rid,@"control_code":string,@"type":_infraredModel.type}];
    NSLog(@"点击：%li",(long)index);
}



#pragma mark --- 懒加载
- (STBView *)containerView
{
    if(!_containerView)
    {
        UIView *superView = self.view;
        _containerView = [[STBView alloc]init];
        [superView addSubview:_containerView];
        _containerView.delegate = self;
    }
    return _containerView;
}




- (void)masLayoutSubview
{
    __weak UIView *superView = self.view;
    [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(superView);
    }];
    
    [superView bringSubviewToFront:self.navigationBar];
    
}


- (void)setNavigationStyle
{
    [self setNavigationBarTitle:@"机顶盒遥控器"];
    [self setRightButtonTitle:@"编辑" titleColor:rgba(143,157,189,1) titleFont:fontWithSize(14)];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
